﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeTop.复习九月份
{
    public class SolBase
    {
        public int Rand7()
        {
            Random random = new Random();
            return random.Next(8);
        }
    }

    /**
   * The Rand7() API is already defined in the parent class SolBase.
   * public int Rand7();
   * @return a random integer in the range 1 to 7
   */

    public class Solution470 : SolBase
    {
        public int Rand10()
        {
            int row, col, idx;
            do
            {
                row = Rand7();
                col = Rand7();
                idx = col + (row - 1) * 7;//这个数是第几个数，（49里面的第几个）
            } while (idx > 40);//必须是前40个才行，否则继续生成
            //目的是随机生成1个（1-40）之间的数

            return 1 + (idx - 1) % 10;//满足条件，余10，返回
        }
    }

    internal class Program470
    {
        private static void Main470(string[] args)
        {
            Solution470 solution470 = new Solution470();
            Console.WriteLine(solution470.Rand10());
            Console.WriteLine(solution470.Rand10());
            Console.WriteLine(solution470.Rand10());
            Console.WriteLine(solution470.Rand10());
            Console.WriteLine(solution470.Rand10());
        }
    }
}